<?php require_once('../../Connections/microassur.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$maxRows_RS = 10;
$pageNum_RS = 0;
if (isset($_GET['pageNum_RS'])) {
  $pageNum_RS = $_GET['pageNum_RS'];
}
$startRow_RS = $pageNum_RS * $maxRows_RS;

mysql_select_db($database_microassur, $microassur);
$query_RS = "SELECT * FROM justificatif";
$query_limit_RS = sprintf("%s LIMIT %d, %d", $query_RS, $startRow_RS, $maxRows_RS);
$RS = mysql_query($query_limit_RS, $microassur) or die(mysql_error());
$row_RS = mysql_fetch_assoc($RS);
$sReqLibJust = "SELECT Nom_element FROM dictionnaire,elementdico where dictionnaire.Code_table='M0010'
					 and dictionnaire.Identifiant_table=elementdico.Identifiant_table
					 and Code_element = '".$row_RS['Type_justificatif']."'";
	$rsLibJust = mysql_query($sReqLibJust, $microassur) or die(mysql_error());
	$rowLibJust = mysql_fetch_assoc($rsLibJust);

if (isset($_GET['totalRows_RS'])) {
  $totalRows_RS = $_GET['totalRows_RS'];
} else {
  $all_RS = mysql_query($query_RS);
  $totalRows_RS = mysql_num_rows($all_RS);
}
$totalPages_RS = ceil($totalRows_RS/$maxRows_RS)-1;

$colname_rs_pers = "-1";
if (isset($_GET['Identifiant_personne'])) {
  $colname_rs_pers = $_GET['Identifiant_personne'];
}
mysql_select_db($database_microassur, $microassur);
$query_rs_pers = sprintf("SELECT * FROM personne WHERE Identifiant_personne = %s", GetSQLValueString($colname_rs_pers, "int"));
$rs_pers = mysql_query($query_rs_pers, $microassur) or die(mysql_error());
$row_rs_pers = mysql_fetch_assoc($rs_pers);
$totalRows_rs_pers = mysql_num_rows($rs_pers);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Document sans titre</title>
</head>

<body>
<table width="520" height="175" border="1" align="center">
  <tr>
    <td colspan="3"><div align="center">JUSTIFICATIFS DE LA PERSONNE</div></td>
    <td width="58" rowspan="3"><p><a href="saisiejustificatif.php?Identifiant_personne=<?php echo $row_rs_pers['Identifiant_personne']; ?>">Créer</a></p>
    <p>&nbsp;</p>
    </td>
  </tr>
  <tr>
    <td width="224" height="23">TYPE</td>
    <td width="216">VALEUR</td>
    <td width="216"></td>

  </tr>
  <?php do { ?>
    <tr>
      <td height="23"><?php echo $rowLibJust['Nom_element']; ?></td>
      <td><?php echo $row_RS['Valeur_justificatif']; ?></td>
      <td width="216"><a href="saisiejustificatif.php?Identifiant_justificatif=<?php echo $row_RS['Identifiant_justificatif']; ?>&amp;Idantifiant_personne=<?php echo $row_rs_pers['Identifiant_personne']; ?>">Modifier</a></td>
    </tr>
    <?php } while ($row_RS = mysql_fetch_assoc($RS)); ?>
  <tr>
    <td colspan="3"><div align="center"><a href="../contrat/saisiepersonne.php?Identifiant_personne=<?php echo $row_rs_pers['Identifiant_personne']; ?>">Retour</a></div></td>
  </tr>
</table>
</body>
</html>
<?php
mysql_free_result($RS);

mysql_free_result($rs_pers);
?>
